import urllib.request
import urllib.parse
import json

url = 'http://localhost:5000/task'
data = {
    "car_pt": "116.414889,39.892966"
}
# data = urllib.parse.urlencode(data).encode('utf-8')  # 这种方式会将数据转换成: "xxx": "xxx",而不是{"xxx": "xxx"}
data = json.dumps(data)
data = bytes(data, 'utf8')
headers = {"Content-Type": "application/json;charset=utf8"}

request = urllib.request.Request(url=url, data=data, headers=headers)
response = urllib.request.urlopen(request)
content = response.read().decode('utf8')

obj = json.loads(content)
print(obj)
